package com.ydj.framework.utils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ThreadUtils {
    public static void sleep(long ms) {
        try {
            Thread.sleep(ms);
        } catch (InterruptedException ignored) {
        }
    }

    public static void printCallStack(String text) {
        StringBuilder sb = new StringBuilder("堆栈信息:" + text + "\n");
        StackTraceElement[] stack = Thread.currentThread().getStackTrace();
        StringBuilder line = new StringBuilder();
        for (int i = 0; i < stack.length; i++) {
            line.append("-");
            sb.append(i).append(line)
                    .append(stack[i].getClassName())
                    .append(".").append(stack[i].getMethodName())
                    .append("\n");

        }
        log.info(sb.toString());
    }
}